package com.app.util;

import com.app.bean.ProjectBean;
import org.apache.log4j.Logger;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

/**
 * Created by IntelliJ IDEA.
 * User: dourmur
 * Date: 12/7/11
 * Time: 2:45 PM
 * To change this template use File | Settings | File Templates.
 */
public class GenerateTable {

    private static Logger logger = Logger.getLogger(GenerateTable.class);

    public static void main(String args[]){
        AnnotationConfiguration cfg = new AnnotationConfiguration();
        cfg.setProperty("hibernate.dialect", "org.hibernate.dialect.MySQLInnoDBDialect");
        cfg.setProperty("hibernate.connection.driver_class", "com.mysql.jdbc.Driver");
        cfg.setProperty("hibernate.connection.url", "jdbc:mysql://localhost/app-portfolio");
        cfg.setProperty("hibernate.connection.username", "root");
        cfg.setProperty("hibernate.connection.password", "");
        cfg.setProperty("hibernate.show_sql", "true");
        cfg.setProperty("hibernate.format_sql", "true");

        //Annotated Classes
        logger.info("Creting tables.");
        cfg.addAnnotatedClass(ProjectBean.class);
        SchemaExport schema = new SchemaExport(cfg);
        schema.create(true, true);
    }

}